package jdklearning.spi;

import java.io.IOException;

import java.net.URL;
import java.util.Enumeration;
import java.util.ServiceLoader;

public class SpiTest {
	
	public static void main(String[] args) throws IOException {
		String fallName = "META-INF/services/" + HelloService.class.getName();
		Enumeration<URL> resources = SpiTest.class.getClassLoader().getResources(fallName);
		while ( resources.hasMoreElements() ){
			System.out.println( resources.nextElement());
		}


		ServiceLoader<HelloService> serviceLoader = ServiceLoader.load(HelloService.class);
		for(HelloService helloService: serviceLoader){
			System.out.println(helloService.hello());
		}
	}

}
